<template>
	<view class="" style="height: 100%;">
		<view class="search-box">
			<u-search placeholder="姓名或手机号" v-model="keyword" shape="square" :clearabled="true" :show-action="true"
				action-text="搜索" :animation="true" :action-style="actionstyle" @custom="custom" @search="custom"> </u-search>
		</view>
		<mescroll-uni :fixed="false" @init="mescrollInit" :height="height" :down="downOption"
			@down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">

			<view class="hehuoren" @click="back(item)" v-for="(item,index) in goods">
				<image src="/static/img/index/hhr.png" style="width: 28px; height: 28px; margin-right: 5px;" mode="widthFix" ></image>
				<view class="hehuoren-right">
					<view class="hehuoren-right-left">
						<view class="title">
							{{item.userName}}  	{{item.phone}}
						</view>
						<view class="text">
							合伙人{{item.inviteCode}}
						</view>
					</view>
					
						<image src="/static/img/index/ic_next_black.png"  style="width: 10px; height: 14px; margin-right: 5px;" mode="widthFix"></image>
					
				</view>
			</view>
	
		</mescroll-uni>
	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	const api = require('../../config/api');
	const util = require('../../utils/util');
	export default {
		mixins: [MescrollMixin], // 使用mixin
		data() {
			return {
				downOption: {
					auto: true //  false 不自动加载 (mixin已处理第一个tab触发downCallback)  true
				},
				upOption: {
					auto: false, // 不自动加载
					noMoreSize: 4,
					textLoading: '加载中 ...', // 加载中的提示文本
					textNoMore: '暂无更多', // 没有更多数据的提示文本
					empty: {
						tip: '暂无相关数据', // 提示
					},
				},
				goods: [
				],
				keyword:'',
			}
		},
		onShow() {
		
		},
		onLoad() {
			const eventChannel = this.getOpenerEventChannel()
			
			// 监听从原页面发送过来的事件
			eventChannel.on('SelectPartner', (data) => {
			  // 在这里处理接收到的数据
			  // console.log('从原页面接收到的数据：', data);
			
			  this.receivedData = data.data // 假设你只对 data.data 感兴趣
			})
		},
		methods: {
			custom(){
				this.downCallback();
			},
			back(item) {
			  console.log(item)
			  // console.log(this.receivedData);
			  if (this.receivedData == '选择合伙人') {
			    uni.$emit('selectPartnerDate', { item })
			    uni.navigateBack({})
			  }
			},
			/*下拉刷新的回调 */
			downCallback() {
				// 这里加载你想下拉刷新的数据, 比如刷新轮播数据
				// loadSwiper();
				// 下拉刷新的回调,默认重置上拉加载列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
				this.mescroll.resetUpScroll()
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				//联网加载数据
				// this.mescroll.endErr();
				let pageNum = page.num; // 页码, 默认从1开始
				let pageSize = page.size; // 页长, 默认每页10条
				const res = util.request(
					api.daihuaboUserallUrl , {
						page: pageNum,
						keyword: this.keyword,
						limit: pageSize,
		
					},
					'GET'
				).then(res => {
					console.log(res);
					//联网成功的回调,隐藏下拉刷新和上拉加载的状态;
					let totalSize = res.data.total;
					this.mescroll.endBySize(res.data.rows.length, totalSize);
					//设置列表数据
					if (page.num == 1) this.goods = []; //如果是第一页需手动制空列表
					this.goods = this.goods.concat(res.data.rows); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			//点击空布局按钮的回调
			emptyClick() {
				uni.showToast({
					title: '点击了按钮,具体逻辑自行实现'
				})
			}
		}
		}
</script>

<style>
	page {
		height: 100%;
		background-color: #F5F1F0;
	}

	.mescroll-upwarp {
		min-height: 0rpx !important;
	}
</style>
<style lang="scss" scoped>
	.mescroll-item{
		background-color: #fff;
		width: 100%;
		// margin: 5px 0;
		padding: 10px;
		font-size: 14px;
		border-bottom: 1px solid #E6E6E6 ;
	}
	.hehuoren{
		margin-top: 8px;
		margin-left: 15px;
		margin-right: 15px;
		padding: 15px;
		background-color: #fff;
		border-radius: 8px;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.hehuoren-right{
		flex: 1;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}
	.hehuoren-right-left{
		.title{
			font-size: 18px;
			font-weight: 600;
			
		}
	}
	.search-box{
		background-color: #fff;
		padding: 5px;
	}
</style>